package app.purchase.a571xz.com.myandroidframe.httpservice.base;

import android.os.Parcel;
import android.os.Parcelable;

import lombok.Data;

@Data
public class AppException implements Parcelable {
    /**
     * code :
     * localizedMessage :
     * paramstr :
     * errMsg : 用户名或密码错误
     * cause : {}
     * errCodeMsg :
     * stackTrace : []
     */

    private String code;
    private String localizedMessage;
    private String paramstr;
    private String errMsg;
    private CauseBean cause;
    private String errCodeMsg;


    public static class CauseBean implements Parcelable {
        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
        }

        public CauseBean() {
        }

        protected CauseBean(Parcel in) {
        }

        public static final Creator<CauseBean> CREATOR = new Creator<CauseBean>() {
            @Override
            public CauseBean createFromParcel(Parcel source) {
                return new CauseBean(source);
            }

            @Override
            public CauseBean[] newArray(int size) {
                return new CauseBean[size];
            }
        };
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.code);
        dest.writeString(this.localizedMessage);
        dest.writeString(this.paramstr);
        dest.writeString(this.errMsg);
        dest.writeParcelable(this.cause, flags);
        dest.writeString(this.errCodeMsg);
    }

    public AppException() {
    }

    protected AppException(Parcel in) {
        this.code = in.readString();
        this.localizedMessage = in.readString();
        this.paramstr = in.readString();
        this.errMsg = in.readString();
        this.cause = in.readParcelable(CauseBean.class.getClassLoader());
        this.errCodeMsg = in.readString();
    }

    public static final Creator<AppException> CREATOR = new Creator<AppException>() {
        @Override
        public AppException createFromParcel(Parcel source) {
            return new AppException(source);
        }

        @Override
        public AppException[] newArray(int size) {
            return new AppException[size];
        }
    };
}
